/**
 * Created with IntelliJ IDEA.
 * Description:[NOIP2013]记数问题
 * User: zjc
 * Date: 2022-05-10
 * Time: 23:32
 */
import java.util.Scanner;
public class Project {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int count = 0;
        String a = "";
        char b = Integer.toString(x).charAt(0);

        String[] s = new String[n + 1];
        for (int i = 1; i <= n; i++) {
            a = i + "";
            for (int j = 0; j < a.length(); j++) {

                if (a.charAt(j) == b) {
                    count++;
                }
            }

        }
        System.out.print(count);
    }
}